package com.losdun.product.domain.vo;

import com.losdun.product.enums.UnitsEnum;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author sword.ye
 * @date 2025/4/24
 **/
@Data
public class AttributePartsVo {

    private Long configId;
    private String configName;
    private String defaultImageUrl;
    private List<PartsTreeNode> partsList;

    @Data
    public static class PartsTreeNode {
        private Long value;
        private String name;
        private String code;
        private String remark;
        private Integer price;
        private String unit;
        private String imageUrl;

        private List<PartsTreeNode> children=new ArrayList<>();

        public PartsTreeNode(String code) {
            this.code = code;
        }

        public String getText(){
            String unitCode=UnitsEnum.getCodeByLabel(unit);
            return name+"（¥"+String.valueOf(price)+"/"+unitCode+"）";
        }
    }
}
